<?php

namespace app\model\plan;

use app\model\staff\Staff;
use app\model\TimeModel;
use think\model\Relation;

class PlanStaff extends TimeModel
{
    protected $type = [
        'study_end_time' => 'timestamp:Y-m-d H:i:s' ,
        'study_start_time' => 'timestamp:Y-m-d H:i:s' ,
        'sign_time' => 'timestamp:Y-m-d H:i:s' ,
    ] ;
    public function plan()
    {
        return $this->belongsTo(Plan::class , 'plan_id' , 'id') ;
    }
    protected $table = 'sj_plan_staff';

    public  static function planStaffInfo($planId , $staffId)
    {
        return  PlanStaff::where('plan_id' , $planId)
            ->where('staff_id' , $staffId)->where('status' , 1)
            ->find() ;
    }

    public function staff(): Relation
    {
        return $this->belongsTo(Staff::class , 'staff_id' , 'id') ;
    }
}